if [ "${TRAVIS_OS_NAME}" = "osx" ] || [ "${PLATFORM}" = "mac" ]; then
target=apple-darwin
-elif [ "${TRAVIS_OS_NAME}" = "linux" ] || [ "${PLATFORM}" = "linux" ] ||
- [ "${TRAVIS_OS_NAME}" = "" ]; then
- target=unknown-linux-gnu
elif [ "${OS}" = "Windows_NT" ] || [ "${PLATFORM}" = "win" ]; then
target=pc-mingw32
windows=1
+elif [ "${TRAVIS_OS_NAME}" = "linux" ] || [ "${PLATFORM}" = "linux" ] ||
+ [ "${TRAVIS_OS_NAME}" = "" ]; then
+ target=unknown-linux-gnu
fi
if [ "${TRAVIS}" = "true" ] && [ "${target}" = "unknown-linux-gnu" ]; then
[project]
-
name = "cargo"
version = "0.0.1-pre"
authors = ["Yehuda Katz <wycats@gmail.com>",
"Carl Lerche <me@carllerche.com>"]
[lib]
-
name = "cargo"
path = "src/cargo/lib.rs"
test = false
doc = false
-[[bin]]
-name = "cargo-build"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-clean"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-git-checkout"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-read-manifest"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-run"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-rustc"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-test"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-bench"
-test = false
-
-[[bin]]
-name = "cargo-verify-project"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-version"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-new"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-doc"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-generate-lockfile"
-test = false
-doc = false
-
-[[bin]]
-name = "cargo-update"
-test = false
-doc = false
-
[[test]]
name = "tests"
endif
TARGET_ROOT = target
-BIN_TARGETS := $(wildcard src/bin/*.rs)
+BIN_TARGETS := cargo
BIN_TARGETS := $(BIN_TARGETS:src/bin/%.rs=%)
BIN_TARGETS := $(filter-out cargo,$(BIN_TARGETS))
rm -rf $$(PKGDIR_$(1))
mkdir -p $$(PKGDIR_$(1))/bin $$(PKGDIR_$(1))/lib/cargo
cp $$(TARGET_$(1))/cargo$$(X) $$(PKGDIR_$(1))/bin
- cp $$(BIN_TARGETS_$(1)) $$(PKGDIR_$(1))/lib/cargo
+ #cp $$(BIN_TARGETS_$(1)) $$(PKGDIR_$(1))/lib/cargo
(cd $$(PKGDIR_$(1)) && find . -type f | sed 's/^\.\///') \
> $$(DISTDIR_$(1))/manifest-$$(PKG_NAME).in
cp src/etc/install.sh $$(PKGDIR_$(1))
--- /dev/null
+use std::io::process::ExitStatus;
+
+use cargo::ops;
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError, CargoError};
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
+use docopt;
+
+docopt!(Options, "
+Execute all benchmarks of a local package
+
+Usage:
+ cargo bench [options] [--] [<args>...]
+
+Options:
+ -h, --help Print this message
+ --no-run Compile, but don't run benchmarks
+ -j N, --jobs N The number of jobs to run in parallel
+ --target TRIPLE Build for the target triple
+ --manifest-path PATH Path to the manifest to build benchmarks for
+ -v, --verbose Use verbose output
+
+All of the trailing arguments are passed to the benchmark binaries generated
+for filtering benchmarks and generally providing options configuring how they
+run.
+", flag_jobs: Option<uint>, flag_target: Option<String>,
+ flag_manifest_path: Option<String>)
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+ shell.set_verbose(options.flag_verbose);
+
+ let mut ops = ops::TestOptions {
+ no_run: options.flag_no_run,
+ compile_opts: ops::CompileOptions {
+ update: false,
+ env: "bench",
+ shell: shell,
+ jobs: options.flag_jobs,
+ target: options.flag_target.as_ref().map(|s| s.as_slice()),
+ dev_deps: true,
+ },
+ };
+
+ let err = try!(ops::run_benches(&root, &mut ops,
+ options.arg_args.as_slice()).map_err(|err| {
+ CliError::from_boxed(err, 101)
+ }));
+ match err {
+ None => Ok(None),
+ Some(err) => {
+ Err(match err.exit {
+ Some(ExitStatus(i)) => CliError::new("", i as uint),
+ _ => CliError::from_boxed(err.mark_human(), 101)
+ })
+ }
+ }
+}
--- /dev/null
+use std::os;
+
+use cargo::core::MultiShell;
+use cargo::ops::CompileOptions;
+use cargo::ops;
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
+use cargo::util::{CliResult, CliError};
+use docopt;
+
+docopt!(Options, "
+Compile a local package and all of its dependencies
+
+Usage:
+ cargo build [options]
+
+Options:
+ -h, --help Print this message
+ -j N, --jobs N The number of jobs to run in parallel
+ --release Build artifacts in release mode, with optimizations
+ --target TRIPLE Build for the target triple
+ -u, --update-remotes Deprecated option, use `cargo update` instead
+ --manifest-path PATH Path to the manifest to compile
+ -v, --verbose Use verbose output
+", flag_jobs: Option<uint>, flag_target: Option<String>,
+ flag_manifest_path: Option<String>)
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ debug!("executing; cmd=cargo-build; args={}", os::args());
+ shell.set_verbose(options.flag_verbose);
+
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+
+ let env = if options.flag_release {
+ "release"
+ } else {
+ "compile"
+ };
+
+ let mut opts = CompileOptions {
+ update: options.flag_update_remotes,
+ env: env,
+ shell: shell,
+ jobs: options.flag_jobs,
+ target: options.flag_target.as_ref().map(|t| t.as_slice()),
+ dev_deps: false,
+ };
+
+ ops::compile(&root, &mut opts).map(|_| None).map_err(|err| {
+ CliError::from_boxed(err, 101)
+ })
+}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-
-use std::io::process::ExitStatus;
-
-use cargo::ops;
-use cargo::execute_main_without_stdin;
-use cargo::core::MultiShell;
-use cargo::util::{CliResult, CliError, CargoError};
-use cargo::util::important_paths::{find_root_manifest_for_cwd};
-
-docopt!(Options, "
-Execute all benchmarks of a local package
-
-Usage:
- cargo-bench [options] [--] [<args>...]
-
-Options:
- -h, --help Print this message
- --no-run Compile, but don't run benchmarks
- -j N, --jobs N The number of jobs to run in parallel
- --target TRIPLE Build for the target triple
- --manifest-path PATH Path to the manifest to build benchmarks for
- -v, --verbose Use verbose output
-
-All of the trailing arguments are passed to the benchmark binaries generated
-for filtering benchmarks and generally providing options configuring how they
-run.
-", flag_jobs: Option<uint>, flag_target: Option<String>,
- flag_manifest_path: Option<String>)
-
-fn main() {
- execute_main_without_stdin(execute, true);
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
- shell.set_verbose(options.flag_verbose);
-
- let mut ops = ops::TestOptions {
- no_run: options.flag_no_run,
- compile_opts: ops::CompileOptions {
- update: false,
- env: "bench",
- shell: shell,
- jobs: options.flag_jobs,
- target: options.flag_target.as_ref().map(|s| s.as_slice()),
- dev_deps: true,
- },
- };
-
- let err = try!(ops::run_benches(&root, &mut ops,
- options.arg_args.as_slice()).map_err(|err| {
- CliError::from_boxed(err, 101)
- }));
- match err {
- None => Ok(None),
- Some(err) => {
- Err(match err.exit {
- Some(ExitStatus(i)) => CliError::new("", i as uint),
- _ => CliError::from_boxed(err.mark_human(), 101)
- })
- }
- }
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-#[phase(plugin, link)] extern crate log;
-
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-
-use std::os;
-use cargo::{execute_main_without_stdin};
-use cargo::ops;
-use cargo::ops::CompileOptions;
-use cargo::core::MultiShell;
-use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::{find_root_manifest_for_cwd};
-
-docopt!(Options, "
-Compile a local package and all of its dependencies
-
-Usage:
- cargo-build [options]
-
-Options:
- -h, --help Print this message
- -j N, --jobs N The number of jobs to run in parallel
- --release Build artifacts in release mode, with optimizations
- --target TRIPLE Build for the target triple
- -u, --update-remotes Deprecated option, use `cargo update` instead
- --manifest-path PATH Path to the manifest to compile
- -v, --verbose Use verbose output
-", flag_jobs: Option<uint>, flag_target: Option<String>,
- flag_manifest_path: Option<String>)
-
-fn main() {
- execute_main_without_stdin(execute, false);
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- debug!("executing; cmd=cargo-build; args={}", os::args());
- shell.set_verbose(options.flag_verbose);
-
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
-
- let env = if options.flag_release {
- "release"
- } else {
- "compile"
- };
-
- let mut opts = CompileOptions {
- update: options.flag_update_remotes,
- env: env,
- shell: shell,
- jobs: options.flag_jobs,
- target: options.flag_target.as_ref().map(|t| t.as_slice()),
- dev_deps: false,
- };
-
- ops::compile(&root, &mut opts).map(|_| None).map_err(|err| {
- CliError::from_boxed(err, 101)
- })
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-#[phase(plugin, link)] extern crate log;
-
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-
-use std::os;
-use cargo::ops;
-use cargo::{execute_main_without_stdin};
-use cargo::core::MultiShell;
-use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::{find_root_manifest_for_cwd};
-
-docopt!(Options, "
-Remove artifacts that cargo has generated in the past
-
-Usage:
- cargo-clean [options]
-
-Options:
- -h, --help Print this message
- --manifest-path PATH Path to the manifest to the package to clean
- -v, --verbose Use verbose output
-", flag_manifest_path: Option<String>)
-
-fn main() {
- execute_main_without_stdin(execute, false);
-}
-
-fn execute(options: Options, _shell: &mut MultiShell) -> CliResult<Option<()>> {
- debug!("executing; cmd=cargo-clean; args={}", os::args());
-
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
-
- ops::clean(&root).map(|_| None).map_err(|err| {
- CliError::from_boxed(err, 101)
- })
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-
-use cargo::ops;
-use cargo::{execute_main_without_stdin};
-use cargo::core::{MultiShell};
-use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::{find_root_manifest_for_cwd};
-
-docopt!(Options, "
-Build a package's documentation
-
-Usage:
- cargo-doc [options]
-
-Options:
- -h, --help Print this message
- --no-deps Don't build documentation for dependencies
- -j N, --jobs N The number of jobs to run in parallel
- -u, --update-remotes Deprecated option, use `cargo update` instead
- --manifest-path PATH Path to the manifest to document
- -v, --verbose Use verbose output
-
-By default the documentation for the local package and all dependencies is
-built. The output is all placed in `target/doc` in rustdoc's usual format.
-", flag_jobs: Option<uint>,
- flag_manifest_path: Option<String>)
-
-fn main() {
- execute_main_without_stdin(execute, false)
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- shell.set_verbose(options.flag_verbose);
-
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
-
- let mut doc_opts = ops::DocOptions {
- all: !options.flag_no_deps,
- compile_opts: ops::CompileOptions {
- update: options.flag_update_remotes,
- env: if options.flag_no_deps {"doc"} else {"doc-all"},
- shell: shell,
- jobs: options.flag_jobs,
- target: None,
- dev_deps: false,
- },
- };
-
- try!(ops::doc(&root, &mut doc_opts).map_err(|err| {
- CliError::from_boxed(err, 101)
- }));
-
- Ok(None)
-}
-
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-#[phase(plugin, link)] extern crate log;
-
-use std::os;
-use cargo::ops;
-use cargo::{execute_main_without_stdin};
-use cargo::core::MultiShell;
-use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::find_root_manifest_for_cwd;
-
-docopt!(Options, "
-Generate the lockfile for a project
-
-Usage:
- cargo-generate-lockfile [options]
-
-Options:
- -h, --help Print this message
- --manifest-path PATH Path to the manifest to generate a lockfile for
- -v, --verbose Use verbose output
-", flag_manifest_path: Option<String>)
-
-fn main() {
- execute_main_without_stdin(execute, false);
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- debug!("executing; cmd=cargo-generate-lockfile; args={}", os::args());
- shell.set_verbose(options.flag_verbose);
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
-
- ops::generate_lockfile(&root, shell)
- .map(|_| None).map_err(|err| CliError::from_boxed(err, 101))
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate url;
-#[phase(plugin, link)] extern crate log;
-
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-
-use cargo::{execute_main_without_stdin};
-use cargo::core::MultiShell;
-use cargo::core::source::{Source, SourceId};
-use cargo::sources::git::{GitSource};
-use cargo::util::{Config, CliResult, CliError, human, ToUrl};
-
-docopt!(Options, "
-Usage:
- cargo-git-checkout [options] --url=URL --reference=REF
-
-Options:
- -h, --help Print this message
- -v, --verbose Use verbose output
-")
-
-fn main() {
- execute_main_without_stdin(execute, false);
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- let Options { flag_url: url, flag_reference: reference, .. } = options;
-
- let url = try!(url.as_slice().to_url().map_err(|e| {
- human(format!("The URL `{}` you passed was \
- not a valid URL: {}", url, e))
- })
- .map_err(|e| CliError::from_boxed(e, 1)));
-
- let source_id = SourceId::for_git(&url, reference.as_slice(), None);
-
- let mut config = try!(Config::new(shell, None, None).map_err(|e| {
- CliError::from_boxed(e, 1)
- }));
- let mut source = GitSource::new(&source_id, &mut config);
-
- try!(source.update().map_err(|e| {
- CliError::new(format!("Couldn't update {}: {}", source, e), 1)
- }));
-
- Ok(None)
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-#[phase(plugin, link)] extern crate log;
-
-use std::os;
-use cargo::ops;
-use cargo::core::MultiShell;
-use cargo::util::{CliResult, CliError};
-
-docopt!(Options, "
-Create a new cargo package at <path>
-
-Usage:
- cargo-new [options] <path>
- cargo-new -h | --help
-
-Options:
- -h, --help Print this message
- --git Initialize a new git repository with a .gitignore
- --bin Use a binary instead of a library template
- -v, --verbose Use verbose output
-")
-
-fn main() {
- cargo::execute_main_without_stdin(execute, false)
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- debug!("executing; cmd=cargo-new; args={}", os::args());
- shell.set_verbose(options.flag_verbose);
-
- let Options { flag_git, flag_bin, arg_path, .. } = options;
-
- let opts = ops::NewOptions {
- git: flag_git,
- path: arg_path.as_slice(),
- bin: flag_bin,
- };
-
- ops::new(opts, shell).map(|_| None).map_err(|err| {
- CliError::from_boxed(err, 101)
- })
-}
-
-
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-
-use cargo::{execute_main_without_stdin};
-use cargo::core::{MultiShell, Package, Source};
-use cargo::util::{CliResult, CliError};
-use cargo::sources::{PathSource};
-
-docopt!(Options, "
-Usage:
- cargo-clean [options] --manifest-path=PATH
-
-Options:
- -h, --help Print this message
- -v, --verbose Use verbose output
-")
-
-fn main() {
- execute_main_without_stdin(execute, false);
-}
-
-fn execute(options: Options, _: &mut MultiShell) -> CliResult<Option<Package>> {
- let path = Path::new(options.flag_manifest_path.as_slice());
- let mut source = try!(PathSource::for_path(&path).map_err(|e| {
- CliError::new(e.description(), 1)
- }));
-
- try!(source.update().map_err(|err| CliError::new(err.description(), 1)));
-
- source
- .get_root_package()
- .map(|pkg| Some(pkg))
- .map_err(|err| CliError::from_boxed(err, 1))
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-
-use std::io::process::ExitStatus;
-
-use cargo::ops;
-use cargo::{execute_main_without_stdin};
-use cargo::core::{MultiShell};
-use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::{find_root_manifest_for_cwd};
-
-docopt!(Options, "
-Run the main binary of the local package (src/main.rs)
-
-Usage:
- cargo-run [options] [--] [<args>...]
-
-Options:
- -h, --help Print this message
- -j N, --jobs N The number of jobs to run in parallel
- -u, --update-remotes Deprecated option, use `cargo update` instead
- --manifest-path PATH Path to the manifest to execute
- -v, --verbose Use verbose output
-
-All of the trailing arguments are passed as to the binary to run.
-", flag_jobs: Option<uint>, flag_target: Option<String>,
- flag_manifest_path: Option<String>)
-
-fn main() {
- execute_main_without_stdin(execute, true);
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- shell.set_verbose(options.flag_verbose);
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
-
- let mut compile_opts = ops::CompileOptions {
- update: options.flag_update_remotes,
- env: "compile",
- shell: shell,
- jobs: options.flag_jobs,
- target: None,
- dev_deps: true,
- };
-
- let err = try!(ops::run(&root, &mut compile_opts,
- options.arg_args.as_slice()).map_err(|err| {
- CliError::from_boxed(err, 101)
- }));
- match err {
- None => Ok(None),
- Some(err) => {
- Err(match err.exit {
- Some(ExitStatus(i)) => CliError::from_boxed(box err, i as uint),
- _ => CliError::from_boxed(box err, 101),
- })
- }
- }
-}
-
+++ /dev/null
-extern crate cargo;
-
-fn main() {
- // Standalone cargo-rustc will go here
- unimplemented!();
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-
-use std::io::process::ExitStatus;
-
-use cargo::ops;
-use cargo::execute_main_without_stdin;
-use cargo::core::MultiShell;
-use cargo::util::{CliResult, CliError, CargoError};
-use cargo::util::important_paths::{find_root_manifest_for_cwd};
-
-docopt!(Options, "
-Execute all unit and integration tests of a local package
-
-Usage:
- cargo-test [options] [--] [<args>...]
-
-Options:
- -h, --help Print this message
- --no-run Compile, but don't run tests
- -j N, --jobs N The number of jobs to run in parallel
- --target TRIPLE Build for the target triple
- -u, --update-remotes Deprecated option, use `cargo update` instead
- --manifest-path PATH Path to the manifest to build tests for
- -v, --verbose Use verbose output
-
-All of the trailing arguments are passed to the test binaries generated for
-filtering tests and generally providing options configuring how they run.
-", flag_jobs: Option<uint>, flag_target: Option<String>,
- flag_manifest_path: Option<String>)
-
-fn main() {
- execute_main_without_stdin(execute, true);
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
- shell.set_verbose(options.flag_verbose);
-
- let mut ops = ops::TestOptions {
- no_run: options.flag_no_run,
- compile_opts: ops::CompileOptions {
- update: options.flag_update_remotes,
- env: "test",
- shell: shell,
- jobs: options.flag_jobs,
- target: options.flag_target.as_ref().map(|s| s.as_slice()),
- dev_deps: true,
- },
- };
-
- let err = try!(ops::run_tests(&root, &mut ops,
- options.arg_args.as_slice()).map_err(|err| {
- CliError::from_boxed(err, 101)
- }));
- match err {
- None => Ok(None),
- Some(err) => {
- Err(match err.exit {
- Some(ExitStatus(i)) => CliError::new("", i as uint),
- _ => CliError::from_boxed(err.mark_human(), 101)
- })
- }
- }
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-#[phase(plugin, link)] extern crate log;
-
-use std::os;
-use cargo::ops;
-use cargo::{execute_main_without_stdin};
-use cargo::core::MultiShell;
-use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::find_root_manifest_for_cwd;
-
-docopt!(Options, "
-Update dependencies as recorded in the local lock file.
-
-Usage:
- cargo-update [options] [<name>]
-
-Options:
- -h, --help Print this message
- --manifest-path PATH Path to the manifest to compile
- -v, --verbose Use verbose output
-
-This command requires that a `Cargo.lock` already exists as generated by
-`cargo build` or related commands.
-
-If <name> is specified, then a conservative update of the lockfile will be
-performed. This means that only the dependency <name> (and all of its transitive
-dependencies) will be updated. All other dependencies will remain locked at
-their currently recorded versions.
-
-If <name> is not specified, then all dependencies will be re-resolved and
-updated.
-", flag_manifest_path: Option<String>, arg_name: Option<String>)
-
-fn main() {
- execute_main_without_stdin(execute, false);
-}
-
-fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- debug!("executing; cmd=cargo-update; args={}", os::args());
- shell.set_verbose(options.flag_verbose);
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
-
- ops::update_lockfile(&root, shell, options.arg_name)
- .map(|_| None).map_err(|err| CliError::from_boxed(err, 101))
-}
-
+++ /dev/null
-#![crate_name="cargo-verify-project"]
-
-extern crate toml;
-extern crate getopts;
-
-use std::io::File;
-use std::os::{args, set_exit_status};
-use getopts::{reqopt, getopts};
-
-/**
- cargo-verify-project --manifest=LOCATION
-*/
-
-fn main() {
- let arguments = args();
-
- let opts = vec!(
- reqopt("m", "manifest", "the location of the manifest", "MANIFEST")
- );
-
- let matches = match getopts(arguments.tail(), opts.as_slice()) {
- Ok(m) => m,
- Err(_) => {
- fail("missing-argument", "manifest");
- return;
- }
- };
-
- let manifest = match matches.opt_str("m") {
- Some(m) => m,
- None => {
- fail("missing-argument", "manifest");
- return;
- }
- };
- let file = Path::new(manifest);
- let contents = match File::open(&file).read_to_string() {
- Ok(s) => s,
- Err(e) => return fail("invalid", format!("error reading file: {}",
- e).as_slice())
- };
- match toml::Parser::new(contents.as_slice()).parse() {
- None => {
- fail("invalid", "invalid-format");
- return;
- },
- Some(..) => {}
- };
-
- println!("{}", "{ \"success\": \"true\" }");
-}
-
-fn fail(reason: &str, value: &str) {
- println!(r#"{{ "{:s}": "{:s}" }}"#, reason, value);
- set_exit_status(1);
-}
+++ /dev/null
-#![feature(phase)]
-
-extern crate serialize;
-extern crate cargo;
-extern crate docopt;
-#[phase(plugin)] extern crate docopt_macros;
-#[phase(plugin, link)] extern crate log;
-
-use std::os;
-use cargo::execute_main_without_stdin;
-use cargo::core::MultiShell;
-use cargo::util::CliResult;
-
-docopt!(Options, "
-Usage:
- cargo-version [options]
-
-Options:
- -h, --help Print this message
- -v, --verbose Use verbose output
-")
-
-fn main() {
- execute_main_without_stdin(execute, false);
-}
-
-fn execute(_: Options, _: &mut MultiShell) -> CliResult<Option<()>> {
- debug!("executing; cmd=cargo-version; args={}", os::args());
-
- println!("{}", cargo::version());
-
- Ok(None)
-}
-#![feature(phase)]
+#![feature(phase, macro_rules)]
extern crate serialize;
#[phase(plugin, link)] extern crate log;
use std::io;
use std::io::fs;
use std::io::process::{Command,InheritFd,ExitStatus,ExitSignal};
-use serialize::Encodable;
use docopt::FlagParser;
use cargo::{execute_main_without_stdin, handle_error, shell};
use cargo::core::MultiShell;
-use cargo::util::important_paths::find_project;
-use cargo::util::{CliError, CliResult, Require, config, human};
+use cargo::util::{CliError, CliResult};
fn main() {
execute_main_without_stdin(execute, true)
See 'cargo help <command>' for more information on a specific command.
")
+macro_rules! each_subcommand( ($macro:ident) => ({
+ $macro!(bench)
+ $macro!(build)
+ $macro!(clean)
+ $macro!(config_for_key)
+ $macro!(config_list)
+ $macro!(doc)
+ $macro!(generate_lockfile)
+ $macro!(git_checkout)
+ $macro!(locate_project)
+ $macro!(new)
+ $macro!(read_manifest)
+ $macro!(run)
+ $macro!(test)
+ $macro!(update)
+ $macro!(verify_project)
+ $macro!(version)
+}) )
+
/**
The top-level `cargo` command handles configuration and project location
because they are fundamental (and intertwined). Other commands can rely
fn execute(flags: Flags, shell: &mut MultiShell) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo; args={}", os::args());
shell.set_verbose(flags.flag_verbose);
+
if flags.flag_list {
println!("Installed Commands:");
- for command in list_commands().iter() {
+ for command in list_commands().move_iter() {
println!(" {}", command);
- // TODO: it might be helpful to add result of -h to each command.
};
return Ok(None)
}
- let mut args = flags.arg_args.clone();
- args.insert(0, flags.arg_command.clone());
- match flags.arg_command.as_slice() {
- "config-for-key" => {
- log!(4, "cmd == config-for-key");
- let r = cargo::call_main_without_stdin(config_for_key, shell,
- args.as_slice(), false);
- cargo::process_executed(r, shell)
- },
- "config-list" => {
- log!(4, "cmd == config-list");
- let r = cargo::call_main_without_stdin(config_list, shell,
- args.as_slice(), false);
- cargo::process_executed(r, shell)
- },
- "locate-project" => {
- log!(4, "cmd == locate-project");
- let r = cargo::call_main_without_stdin(locate_project, shell,
- args.as_slice(), false);
- cargo::process_executed(r, shell)
- },
- // If we are invoked with no arguments or with `help` with no
- // arguments, re-invoke ourself with `-h` to get the help
- // message printed
+
+ let (mut args, command) = match flags.arg_command.as_slice() {
"" | "help" if flags.arg_args.len() == 0 => {
shell.set_verbose(true);
let r = cargo::call_main_without_stdin(execute, shell,
["-h".to_string()], false);
- cargo::process_executed(r, shell)
- },
- orig_cmd => {
- let is_help = orig_cmd == "help";
- let cmd = if is_help {
- flags.arg_args[0].as_slice()
- } else {
- orig_cmd
- };
- execute_subcommand(cmd, is_help, &flags, shell)
+ cargo::process_executed(r, shell);
+ return Ok(None)
}
- }
+ "help" => (vec!["-h".to_string()], flags.arg_args[0].as_slice()),
+ s => (flags.arg_args.clone(), s),
+ };
+ args.insert(0, command.to_string());
+
+ macro_rules! cmd( ($name:ident) => (
+ if command.as_slice() == stringify!($name).replace("_", "-").as_slice() {
+ mod $name;
+ shell.set_verbose(true);
+ let r = cargo::call_main_without_stdin($name::execute, shell,
+ args.as_slice(),
+ false);
+ cargo::process_executed(r, shell);
+ return Ok(None)
+ }
+ ) )
+ each_subcommand!(cmd)
+
+ execute_subcommand(command.as_slice(), args.as_slice(), shell);
Ok(None)
}
-fn execute_subcommand(cmd: &str, is_help: bool, flags: &Flags, shell: &mut MultiShell) -> () {
- match find_command(cmd) {
- Some(command) => {
- let mut command = Command::new(command);
- let command = if is_help {
- command.arg("-h")
- } else {
- command.args(flags.arg_args.as_slice())
- };
- let status = command
- .stdin(InheritFd(0))
- .stdout(InheritFd(1))
- .stderr(InheritFd(2))
- .status();
-
- match status {
- Ok(ExitStatus(0)) => (),
- Ok(ExitStatus(i)) => {
- handle_error(CliError::new("", i as uint), shell)
- }
- Ok(ExitSignal(i)) => {
- let msg = format!("subcommand failed with signal: {}", i);
- handle_error(CliError::new(msg, i as uint), shell)
- }
- Err(io::IoError{kind, ..}) if kind == io::FileNotFound =>
- handle_error(CliError::new("No such subcommand", 127), shell),
- Err(err) => handle_error(
- CliError::new(
- format!("Subcommand failed to run: {}", err), 127),
- shell)
- }
- },
- None => handle_error(CliError::new("No such subcommand", 127), shell)
+fn execute_subcommand(cmd: &str, args: &[String], shell: &mut MultiShell) {
+ let command = match find_command(cmd) {
+ Some(command) => command,
+ None => return handle_error(CliError::new("No such subcommand", 127),
+ shell)
+ };
+ let status = Command::new(command)
+ .args(args)
+ .stdin(InheritFd(0))
+ .stdout(InheritFd(1))
+ .stderr(InheritFd(2))
+ .status();
+
+ match status {
+ Ok(ExitStatus(0)) => (),
+ Ok(ExitStatus(i)) => {
+ handle_error(CliError::new("", i as uint), shell)
+ }
+ Ok(ExitSignal(i)) => {
+ let msg = format!("subcommand failed with signal: {}", i);
+ handle_error(CliError::new(msg, i as uint), shell)
+ }
+ Err(io::IoError{kind, ..}) if kind == io::FileNotFound =>
+ handle_error(CliError::new("No such subcommand", 127), shell),
+ Err(err) => handle_error(
+ CliError::new(
+ format!("Subcommand failed to run: {}", err), 127),
+ shell)
}
}
}
}
}
+
+ macro_rules! add_cmd( ($cmd:ident) => ({
+ commands.insert(stringify!($cmd).replace("_", "-"));
+ }) )
+ each_subcommand!(add_cmd);
commands
}
fn is_executable(path: &Path) -> bool {
match fs::stat(path) {
- Ok(io::FileStat{kind, perm, ..}) =>
- (kind == io::TypeFile) && perm.contains(io::OtherExecute),
+ Ok(io::FileStat{ kind: io::TypeFile, perm, ..}) =>
+ perm.contains(io::OtherExecute),
_ => false
}
}
};
dirs
}
-
-#[deriving(Encodable)]
-struct ConfigOut {
- values: std::collections::HashMap<String, config::ConfigValue>
-}
-
-docopt!(ConfigForKeyFlags, "
-Usage: cargo config-for-key --human --key=<key>
-")
-
-fn config_for_key(args: ConfigForKeyFlags,
- _: &mut MultiShell) -> CliResult<Option<ConfigOut>> {
- let value = try!(config::get_config(os::getcwd(),
- args.flag_key.as_slice()).map_err(|_| {
- CliError::new("Couldn't load configuration", 1)
- }));
-
- if args.flag_human {
- println!("{}", value);
- Ok(None)
- } else {
- let mut map = std::collections::HashMap::new();
- map.insert(args.flag_key.clone(), value);
- Ok(Some(ConfigOut { values: map }))
- }
-}
-
-docopt!(ConfigListFlags, "
-Usage: cargo config-list --human
-")
-
-fn config_list(args: ConfigListFlags, _: &mut MultiShell) -> CliResult<Option<ConfigOut>> {
- let configs = try!(config::all_configs(os::getcwd()).map_err(|_|
- CliError::new("Couldn't load configuration", 1)));
-
- if args.flag_human {
- for (key, value) in configs.iter() {
- println!("{} = {}", key, value);
- }
- Ok(None)
- } else {
- Ok(Some(ConfigOut { values: configs }))
- }
-}
-
-docopt!(LocateProjectFlags, "
-Usage: cargo locate-project
-")
-
-#[deriving(Encodable)]
-struct ProjectLocation {
- root: String
-}
-
-fn locate_project(_: LocateProjectFlags,
- _: &mut MultiShell) -> CliResult<Option<ProjectLocation>> {
- let root = try!(find_project(&os::getcwd(), "Cargo.toml").map_err(|e| {
- CliError::from_boxed(e, 1)
- }));
-
- let string = try!(root.as_str()
- .require(|| human("Your project path contains characters \
- not representable in Unicode"))
- .map_err(|e| CliError::from_boxed(e, 1)));
-
- Ok(Some(ProjectLocation { root: string.to_string() }))
-}
--- /dev/null
+use std::os;
+use docopt;
+
+use cargo::ops;
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError};
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
+
+docopt!(Options, "
+Remove artifacts that cargo has generated in the past
+
+Usage:
+ cargo clean [options]
+
+Options:
+ -h, --help Print this message
+ --manifest-path PATH Path to the manifest to the package to clean
+ -v, --verbose Use verbose output
+", flag_manifest_path: Option<String>)
+
+pub fn execute(options: Options, _shell: &mut MultiShell) -> CliResult<Option<()>> {
+ debug!("executing; cmd=cargo-clean; args={}", os::args());
+
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+
+ ops::clean(&root).map(|_| None).map_err(|err| {
+ CliError::from_boxed(err, 101)
+ })
+}
--- /dev/null
+use std::os;
+use std::collections::HashMap;
+use docopt;
+
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError, config};
+
+#[deriving(Encodable)]
+struct ConfigOut {
+ values: HashMap<String, config::ConfigValue>
+}
+
+docopt!(ConfigForKeyFlags, "
+Usage: cargo config-for-key --human --key=<key>
+")
+
+pub fn execute(args: ConfigForKeyFlags,
+ _: &mut MultiShell) -> CliResult<Option<ConfigOut>> {
+ let value = try!(config::get_config(os::getcwd(),
+ args.flag_key.as_slice()).map_err(|_| {
+ CliError::new("Couldn't load configuration", 1)
+ }));
+
+ if args.flag_human {
+ println!("{}", value);
+ Ok(None)
+ } else {
+ let mut map = HashMap::new();
+ map.insert(args.flag_key.clone(), value);
+ Ok(Some(ConfigOut { values: map }))
+ }
+}
--- /dev/null
+use std::os;
+use std::collections::HashMap;
+use docopt;
+
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError, config};
+
+#[deriving(Encodable)]
+struct ConfigOut {
+ values: HashMap<String, config::ConfigValue>
+}
+
+docopt!(ConfigListFlags, "
+Usage: cargo config-list --human
+")
+
+pub fn execute(args: ConfigListFlags,
+ _: &mut MultiShell) -> CliResult<Option<ConfigOut>> {
+ let configs = try!(config::all_configs(os::getcwd()).map_err(|_|
+ CliError::new("Couldn't load configuration", 1)));
+
+ if args.flag_human {
+ for (key, value) in configs.iter() {
+ println!("{} = {}", key, value);
+ }
+ Ok(None)
+ } else {
+ Ok(Some(ConfigOut { values: configs }))
+ }
+}
--- /dev/null
+use docopt;
+
+use cargo::ops;
+use cargo::core::{MultiShell};
+use cargo::util::{CliResult, CliError};
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
+
+docopt!(Options, "
+Build a package's documentation
+
+Usage:
+ cargo doc [options]
+
+Options:
+ -h, --help Print this message
+ --no-deps Don't build documentation for dependencies
+ -j N, --jobs N The number of jobs to run in parallel
+ -u, --update-remotes Deprecated option, use `cargo update` instead
+ --manifest-path PATH Path to the manifest to document
+ -v, --verbose Use verbose output
+
+By default the documentation for the local package and all dependencies is
+built. The output is all placed in `target/doc` in rustdoc's usual format.
+", flag_jobs: Option<uint>,
+ flag_manifest_path: Option<String>)
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ shell.set_verbose(options.flag_verbose);
+
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+
+ let mut doc_opts = ops::DocOptions {
+ all: !options.flag_no_deps,
+ compile_opts: ops::CompileOptions {
+ update: options.flag_update_remotes,
+ env: if options.flag_no_deps {"doc"} else {"doc-all"},
+ shell: shell,
+ jobs: options.flag_jobs,
+ target: None,
+ dev_deps: false,
+ },
+ };
+
+ try!(ops::doc(&root, &mut doc_opts).map_err(|err| {
+ CliError::from_boxed(err, 101)
+ }));
+
+ Ok(None)
+}
+
--- /dev/null
+use std::os;
+use docopt;
+
+use cargo::ops;
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError};
+use cargo::util::important_paths::find_root_manifest_for_cwd;
+
+docopt!(Options, "
+Generate the lockfile for a project
+
+Usage:
+ cargo generate-lockfile [options]
+
+Options:
+ -h, --help Print this message
+ --manifest-path PATH Path to the manifest to generate a lockfile for
+ -v, --verbose Use verbose output
+", flag_manifest_path: Option<String>)
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ debug!("executing; cmd=cargo-generate-lockfile; args={}", os::args());
+ shell.set_verbose(options.flag_verbose);
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+
+ ops::generate_lockfile(&root, shell)
+ .map(|_| None).map_err(|err| CliError::from_boxed(err, 101))
+}
--- /dev/null
+use docopt;
+
+use cargo::core::MultiShell;
+use cargo::core::source::{Source, SourceId};
+use cargo::sources::git::{GitSource};
+use cargo::util::{Config, CliResult, CliError, human, ToUrl};
+
+docopt!(Options, "
+Usage:
+ cargo git-checkout [options] --url=URL --reference=REF
+
+Options:
+ -h, --help Print this message
+ -v, --verbose Use verbose output
+")
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ let Options { flag_url: url, flag_reference: reference, .. } = options;
+
+ let url = try!(url.as_slice().to_url().map_err(|e| {
+ human(format!("The URL `{}` you passed was \
+ not a valid URL: {}", url, e))
+ })
+ .map_err(|e| CliError::from_boxed(e, 1)));
+
+ let source_id = SourceId::for_git(&url, reference.as_slice(), None);
+
+ let mut config = try!(Config::new(shell, None, None).map_err(|e| {
+ CliError::from_boxed(e, 1)
+ }));
+ let mut source = GitSource::new(&source_id, &mut config);
+
+ try!(source.update().map_err(|e| {
+ CliError::new(format!("Couldn't update {}: {}", source, e), 1)
+ }));
+
+ Ok(None)
+}
--- /dev/null
+use docopt;
+
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError, human, Require};
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
+
+docopt!(LocateProjectFlags, "
+Usage:
+ cargo locate-project [options]
+
+Options:
+ --manifest-path PATH Path to the manifest to build benchmarks for
+", flag_manifest_path: Option<String>)
+
+#[deriving(Encodable)]
+struct ProjectLocation {
+ root: String
+}
+
+pub fn execute(flags: LocateProjectFlags,
+ _: &mut MultiShell) -> CliResult<Option<ProjectLocation>> {
+ let root = try!(find_root_manifest_for_cwd(flags.flag_manifest_path));
+
+ let string = try!(root.as_str()
+ .require(|| human("Your project path contains characters \
+ not representable in Unicode"))
+ .map_err(|e| CliError::from_boxed(e, 1)));
+
+ Ok(Some(ProjectLocation { root: string.to_string() }))
+}
--- /dev/null
+use std::os;
+use docopt;
+
+use cargo::ops;
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError};
+
+docopt!(Options, "
+Create a new cargo package at <path>
+
+Usage:
+ cargo new [options] <path>
+ cargo new -h | --help
+
+Options:
+ -h, --help Print this message
+ --git Initialize a new git repository with a .gitignore
+ --bin Use a binary instead of a library template
+ -v, --verbose Use verbose output
+")
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ debug!("executing; cmd=cargo-new; args={}", os::args());
+ shell.set_verbose(options.flag_verbose);
+
+ let Options { flag_git, flag_bin, arg_path, .. } = options;
+
+ let opts = ops::NewOptions {
+ git: flag_git,
+ path: arg_path.as_slice(),
+ bin: flag_bin,
+ };
+
+ ops::new(opts, shell).map(|_| None).map_err(|err| {
+ CliError::from_boxed(err, 101)
+ })
+}
+
+
--- /dev/null
+use docopt;
+
+use cargo::core::{MultiShell, Package, Source};
+use cargo::util::{CliResult, CliError};
+use cargo::sources::{PathSource};
+
+docopt!(Options, "
+Usage:
+ cargo clean [options] --manifest-path=PATH
+
+Options:
+ -h, --help Print this message
+ -v, --verbose Use verbose output
+")
+
+pub fn execute(options: Options, _: &mut MultiShell) -> CliResult<Option<Package>> {
+ let path = Path::new(options.flag_manifest_path.as_slice());
+ let mut source = try!(PathSource::for_path(&path).map_err(|e| {
+ CliError::new(e.description(), 1)
+ }));
+
+ try!(source.update().map_err(|err| CliError::new(err.description(), 1)));
+
+ source
+ .get_root_package()
+ .map(|pkg| Some(pkg))
+ .map_err(|err| CliError::from_boxed(err, 1))
+}
--- /dev/null
+use std::io::process::ExitStatus;
+use docopt;
+
+use cargo::ops;
+use cargo::core::{MultiShell};
+use cargo::util::{CliResult, CliError};
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
+
+docopt!(Options, "
+Run the main binary of the local package (src/main.rs)
+
+Usage:
+ cargo run [options] [--] [<args>...]
+
+Options:
+ -h, --help Print this message
+ -j N, --jobs N The number of jobs to run in parallel
+ -u, --update-remotes Deprecated option, use `cargo update` instead
+ --manifest-path PATH Path to the manifest to execute
+ -v, --verbose Use verbose output
+
+All of the trailing arguments are passed as to the binary to run.
+", flag_jobs: Option<uint>, flag_target: Option<String>,
+ flag_manifest_path: Option<String>)
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ shell.set_verbose(options.flag_verbose);
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+
+ let mut compile_opts = ops::CompileOptions {
+ update: options.flag_update_remotes,
+ env: "compile",
+ shell: shell,
+ jobs: options.flag_jobs,
+ target: None,
+ dev_deps: true,
+ };
+
+ let err = try!(ops::run(&root, &mut compile_opts,
+ options.arg_args.as_slice()).map_err(|err| {
+ CliError::from_boxed(err, 101)
+ }));
+ match err {
+ None => Ok(None),
+ Some(err) => {
+ Err(match err.exit {
+ Some(ExitStatus(i)) => CliError::from_boxed(box err, i as uint),
+ _ => CliError::from_boxed(box err, 101),
+ })
+ }
+ }
+}
+
--- /dev/null
+use std::io::process::ExitStatus;
+use docopt;
+
+use cargo::ops;
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError, CargoError};
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
+
+docopt!(Options, "
+Execute all unit and integration tests of a local package
+
+Usage:
+ cargo test [options] [--] [<args>...]
+
+Options:
+ -h, --help Print this message
+ --no-run Compile, but don't run tests
+ -j N, --jobs N The number of jobs to run in parallel
+ --target TRIPLE Build for the target triple
+ -u, --update-remotes Deprecated option, use `cargo update` instead
+ --manifest-path PATH Path to the manifest to build tests for
+ -v, --verbose Use verbose output
+
+All of the trailing arguments are passed to the test binaries generated for
+filtering tests and generally providing options configuring how they run.
+", flag_jobs: Option<uint>, flag_target: Option<String>,
+ flag_manifest_path: Option<String>)
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+ shell.set_verbose(options.flag_verbose);
+
+ let mut ops = ops::TestOptions {
+ no_run: options.flag_no_run,
+ compile_opts: ops::CompileOptions {
+ update: options.flag_update_remotes,
+ env: "test",
+ shell: shell,
+ jobs: options.flag_jobs,
+ target: options.flag_target.as_ref().map(|s| s.as_slice()),
+ dev_deps: true,
+ },
+ };
+
+ let err = try!(ops::run_tests(&root, &mut ops,
+ options.arg_args.as_slice()).map_err(|err| {
+ CliError::from_boxed(err, 101)
+ }));
+ match err {
+ None => Ok(None),
+ Some(err) => {
+ Err(match err.exit {
+ Some(ExitStatus(i)) => CliError::new("", i as uint),
+ _ => CliError::from_boxed(err.mark_human(), 101)
+ })
+ }
+ }
+}
--- /dev/null
+use std::os;
+use docopt;
+
+use cargo::ops;
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError};
+use cargo::util::important_paths::find_root_manifest_for_cwd;
+
+docopt!(Options, "
+Update dependencies as recorded in the local lock file.
+
+Usage:
+ cargo update [options] [<name>]
+
+Options:
+ -h, --help Print this message
+ --manifest-path PATH Path to the manifest to compile
+ -v, --verbose Use verbose output
+
+This command requires that a `Cargo.lock` already exists as generated by
+`cargo build` or related commands.
+
+If <name> is specified, then a conservative update of the lockfile will be
+performed. This means that only the dependency <name> (and all of its transitive
+dependencies) will be updated. All other dependencies will remain locked at
+their currently recorded versions.
+
+If <name> is not specified, then all dependencies will be re-resolved and
+updated.
+", flag_manifest_path: Option<String>, arg_name: Option<String>)
+
+pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
+ debug!("executing; cmd=cargo-update; args={}", os::args());
+ shell.set_verbose(options.flag_verbose);
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+
+ ops::update_lockfile(&root, shell, options.arg_name)
+ .map(|_| None).map_err(|err| CliError::from_boxed(err, 101))
+}
+
--- /dev/null
+extern crate toml;
+
+use std::collections::HashMap;
+use std::io::File;
+use std::os;
+use docopt;
+
+use cargo::core::MultiShell;
+use cargo::util::CliResult;
+
+pub type Error = HashMap<String, String>;
+
+docopt!(Flags, "
+Usage:
+ cargo verify-project [options] --manifest-path PATH
+
+Options:
+ -h, --help Print this message
+ --manifest-path PATH Path to the manifest to verify
+ -v, --verbose Use verbose output
+")
+
+pub fn execute(args: Flags,
+ shell: &mut MultiShell) -> CliResult<Option<Error>> {
+ shell.set_verbose(args.flag_verbose);
+
+ let file = Path::new(args.flag_manifest_path);
+ let contents = match File::open(&file).read_to_string() {
+ Ok(s) => s,
+ Err(e) => return fail("invalid", format!("error reading file: {}",
+ e).as_slice())
+ };
+ match toml::Parser::new(contents.as_slice()).parse() {
+ None => return fail("invalid", "invalid-format"),
+ Some(..) => {}
+ };
+
+ let mut h = HashMap::new();
+ h.insert("success".to_string(), "true".to_string());
+ Ok(Some(h))
+}
+
+fn fail(reason: &str, value: &str) -> CliResult<Option<Error>>{
+ let mut h = HashMap::new();
+ h.insert(reason.to_string(), value.to_string());
+ os::set_exit_status(1);
+ Ok(Some(h))
+}
--- /dev/null
+use std::os;
+use docopt;
+
+use cargo;
+use cargo::core::MultiShell;
+use cargo::util::CliResult;
+
+docopt!(Options, "
+Usage:
+ cargo version [options]
+
+Options:
+ -h, --help Print this message
+ -v, --verbose Use verbose output
+")
+
+pub fn execute(_: Options, _: &mut MultiShell) -> CliResult<Option<()>> {
+ debug!("executing; cmd=cargo-version; args={}", os::args());
+
+ println!("{}", cargo::version());
+
+ Ok(None)
+}
.env("HOME", Some(paths::home().display().to_string().as_slice()))
}
- pub fn cargo_process(&self, program: &str) -> ProcessBuilder {
+ pub fn cargo_process(&self, cmd: &str) -> ProcessBuilder {
self.build();
- self.process(cargo_dir().join(program))
+ self.process(cargo_dir().join("cargo")).arg(cmd)
}
pub fn file<B: BytesContainer, S: Str>(mut self, path: B,
-use cargo::util::{process, ProcessBuilder};
-use hamcrest::{assert_that};
-use std::io;
use std::io::fs;
+use std::io;
use std::os;
+use std::str;
+use cargo::util::{process, ProcessBuilder};
+
use support::paths;
-use support::{project, execs, cargo_dir, mkdir_recursive, ProjectBuilder, ResultTest};
+use support::{project, cargo_dir, mkdir_recursive, ProjectBuilder, ResultTest};
fn setup() {
}
!p.join(format!("cargo{}", os::consts::EXE_SUFFIX)).exists()
}).collect()
}
-
-test!(list_commands_empty {
- let proj = project("list-runs");
- let pr = copied_executable_process(&proj, "cargo", &Path::new("bin"));
- let new_path = os::join_paths(new_path().as_slice()).unwrap();
- assert_that(pr.arg("-v").arg("--list").env("PATH", Some(new_path.as_slice())),
- execs().with_status(0)
- .with_stdout("Installed Commands:\n"));
-})
-
test!(list_commands_non_overlapping {
// lib/cargo | cargo-3
// bin/ | cargo-2
let mut path = new_path();
path.push(proj.root().join("path-test"));
let path = os::join_paths(path.as_slice()).unwrap();
- assert_that(pr.arg("-v").arg("--list").env("PATH", Some(path.as_slice())),
- execs().with_status(0)
- .with_stdout("Installed Commands:\n 1\n 2\n 3\n"));
+ let output = pr.arg("-v").arg("--list").env("PATH", Some(path.as_slice()));
+ let output = output.exec_with_output().assert();
+ let output = str::from_utf8(output.output.as_slice()).assert();
+ assert!(output.contains("\n 1\n"), "missing 1: {}", output);
+ assert!(output.contains("\n 2\n"), "missing 2: {}", output);
+ assert!(output.contains("\n 3\n"), "missing 3: {}", output);
})
assert_eq!(hello(), "hello")
}"#);
- assert_that(p.cargo_process("cargo-build"), execs());
+ assert_that(p.cargo_process("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(
process(p.bin("foo")),
execs().with_stdout("hello\n"));
- assert_that(p.process(cargo_dir().join("cargo-bench")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("bench"),
execs().with_stdout(format!("\
{} foo v0.5.0 ({})
{} target[..]release[..]foo
#[bench] fn bench_hello(_b: &mut test::Bencher) {}
"#);
- assert_that(p.cargo_process("cargo-bench").arg("-v").arg("hello"),
+ assert_that(p.cargo_process("bench").arg("-v").arg("hello"),
execs().with_stdout(format!("\
{running} `rustc src[..]foo.rs [..]`
{compiling} foo v0.5.0 ({url})
#[bench] fn bench_bench(_b: &mut test::Bencher) { foo::foo() }
"#);
- let output = p.cargo_process("cargo-bench").exec_with_output().assert();
+ let output = p.cargo_process("bench").exec_with_output().assert();
let output = str::from_utf8(output.output.as_slice()).assert();
assert!(output.contains("test bin_bench"), "bin_bench missing\n{}", output);
assert!(output.contains("test lib_bench"), "lib_bench missing\n{}", output);
assert_eq!(hello(), "nope")
}"#);
- assert_that(p.cargo_process("cargo-build"), execs());
+ assert_that(p.cargo_process("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(
process(p.bin("foo")),
execs().with_stdout("hello\n"));
- assert_that(p.process(cargo_dir().join("cargo-bench")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("bench"),
execs().with_stdout(format!("\
{} foo v0.5.0 ({})
{} target[..]release[..]foo
fn bin_bench(_b: &mut test::Bencher) {}
");
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_stdout(format!("\
{} foo v0.0.1 ({})
{running} target[..]release[..]baz-[..]
");
p2.build();
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
fn external_bench(_b: &mut test::Bencher) {}
"#);
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_stdout(format!("\
{} foo v0.0.1 ({})
{running} target[..]release[..]bench-[..]
fn external_bench(_b: &mut test::Bencher) {}
"#);
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_stdout(format!("\
{} foo v0.0.1 ({})
{running} target[..]release[..]external-[..]
.file("examples/dont-run-me-i-will-fail.rs", r#"
fn main() { fail!("Examples should not be run by 'cargo test'"); }
"#);
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_status(0));
})
#[bench] fn bar(_b: &mut test::Bencher) {}
");
- assert_that(p.cargo_process("cargo-bench").arg("bar"),
+ assert_that(p.cargo_process("bench").arg("bar"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
doctest = DOCTEST,
dir = p.url()).as_slice()));
- assert_that(p.cargo_process("cargo-bench").arg("foo"),
+ assert_that(p.cargo_process("bench").arg("foo"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
fn dummy_bench(b: &mut test::Bencher) { }
"#);
- p.cargo_process("cargo-build");
+ p.cargo_process("build");
for _ in range(0u, 2) {
- assert_that(p.process(cargo_dir().join("cargo-bench")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("bench"),
execs().with_status(0));
}
})
fn bin_bench(_b: &mut test::Bencher) {}
");
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_stdout(format!("\
{} foo v0.0.1 ({})
{running} target[..]release[..]foo-[..]
fn bench(_b: &mut test::Bencher) { syntax::foo() }
");
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} syntax v0.0.1 ({dir})
fn bench(_b: &mut test::Bencher) { syntax::foo() }
");
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} syntax v0.0.1 ({dir})
}
"#);
- let output = p.cargo_process("cargo-bench").exec_with_output().assert();
+ let output = p.cargo_process("bench").exec_with_output().assert();
let output = str::from_utf8(output.output.as_slice()).assert();
assert!(output.contains("main_bench ... bench: 0 ns/iter (+/- 0)"),
"no main_bench\n{}",
pub fn baz() {}
");
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} bar v0.0.1 ({dir})
doctest = DOCTEST,
dir = p.url()).as_slice()));
p.root().move_into_the_past().assert();
- assert_that(p.process(cargo_dir().join("cargo-bench")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("bench"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} bar v0.0.1 ({dir})
fn foo(_b: &mut test::Bencher) {}
");
- assert_that(p.cargo_process("cargo-bench"),
+ assert_that(p.cargo_process("bench"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
doctest = DOCTEST,
dir = p.url()).as_slice()));
- assert_that(p.process(cargo_dir().join("cargo-bench")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("bench"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} foo v0.0.1 ({dir})
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
.file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice());
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(&p.build_dir(), existing_dir());
- assert_that(p.process(cargo_dir().join("cargo-clean")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("clean"),
execs().with_status(0));
assert_that(&p.build_dir(), is_not(existing_dir()));
})
.file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice())
.file("src/bar/a.rs", "");
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(&p.build_dir(), existing_dir());
- assert_that(p.process(cargo_dir().join("cargo-clean"))
+ assert_that(p.process(cargo_dir().join("cargo")).arg("clean")
.cwd(p.root().join("src")),
execs().with_status(0).with_stdout(""));
assert_that(&p.build_dir(), is_not(existing_dir()));
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
.file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice());
- assert_that(p.cargo_process("cargo-build"), execs());
+ assert_that(p.cargo_process("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
.file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice());
- assert_that(p.cargo_process("cargo-build")
+ assert_that(p.cargo_process("build")
.arg("--manifest-path").arg("foo/Cargo.toml")
.cwd(p.root().dir_path()),
execs().with_status(0));
let p = project("foo")
.file("Cargo.toml", "");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs()
.with_status(101)
.with_stderr("Cargo.toml is not a valid manifest\n\n\
foo = bar
");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs()
.with_status(101)
.with_stderr("could not parse input TOML\n\
version = "1.0"
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs()
.with_status(101)
.with_stderr("Cargo.toml is not a valid manifest\n\n\
let tmpdir = TempDir::new("cargo").unwrap();
let p = ProjectBuilder::new("foo", tmpdir.path().clone());
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs()
.with_status(102)
.with_stderr("Could not find Cargo.toml in this directory or any \
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
.file("src/foo.rs", "invalid rust code!");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs()
.with_status(101)
.with_stderr(format!("\
.file("src/lib.rs", "invalid rust code!");
bar.build();
baz.build();
- assert_that(p.cargo_process("cargo-build"), execs().with_status(101));
+ assert_that(p.cargo_process("build"), execs().with_status(101));
})
test!(cargo_compile_with_warnings_in_the_root_package {
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
.file("src/foo.rs", "fn main() {} fn dead() {}");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs()
.with_stderr(format!("\
{filename}:1:14: 1:26 warning: code is never used: `dead`, #[warn(dead_code)] \
let bar = realpath(&p.root().join("bar")).assert();
let main = realpath(&p.root()).assert();
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs()
.with_stdout(format!("{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
}
"#);
- p.cargo_process("cargo-build")
+ p.cargo_process("build")
.exec_with_output()
.assert();
}
"#);
- p.cargo_process("cargo-build")
+ p.cargo_process("build")
.exec_with_output()
.assert();
}
"#);
- p.cargo_process("cargo-build")
+ p.cargo_process("build")
.exec_with_output()
.assert();
}
"#);
- assert_that(p.cargo_process("cargo-build"), execs());
+ assert_that(p.cargo_process("build"), execs());
assert_that(&p.bin("foo"), existing_file());
.file("bar/Cargo.toml", basic_bin_manifest("bar").as_slice())
.file("bar/src/bar.rs", main_file(r#""i am bar""#, []).as_slice());
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr(format!(
r#"No package named `notquitebar` found (required by `foo`).
Location searched: {proj_dir}
.file("src/foo.rs", r#"
fn main() { println!("Hello!"); }
"#);
- assert_that(build.cargo_process("cargo-build"),
+ assert_that(build.cargo_process("build"),
execs().with_status(0));
.file("src/foo.rs", r#"
fn main() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stdout(format!(" Compiling foo v0.5.0 ({})\n",
p.url()))
assert_eq!(args.get(2), &"world".to_string());
}
"#);
- assert_that(build1.cargo_process("cargo-build"),
+ assert_that(build1.cargo_process("build"),
execs().with_status(0));
let mut build2 = project("builder2");
assert_eq!(args.get(1), &"cargo".to_string());
}
"#);
- assert_that(build2.cargo_process("cargo-build"),
+ assert_that(build2.cargo_process("build"),
execs().with_status(0));
let mut p = project("foo");
.file("src/foo.rs", r#"
fn main() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stdout(format!(" Compiling foo v0.5.0 ({})\n",
p.url()))
.file("src/foo.rs", r#"
fn main() { fail!("nope") }
"#);
- assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(build.cargo_process("build"), execs().with_status(0));
let mut p = project("foo");
.file("src/foo.rs", r#"
fn main() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr(format!("\
Process didn't exit successfully: `{}` (status=101)\n\
--- stderr\n\
.file("src/foo.rs", r#"
fn main() { println!("Hello!"); }
"#);
- assert_that(build1.cargo_process("cargo-build"),
+ assert_that(build1.cargo_process("build"),
execs().with_status(0));
let mut build2 = project("builder2");
.file("src/bar.rs", r#"
fn main() { fail!("nope") }
"#);
- assert_that(build2.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(build2.cargo_process("build"), execs().with_status(0));
let mut p = project("foo");
.file("src/foo.rs", r#"
fn main() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr(format!("\
Process didn't exit successfully: `{}` (status=101)\n\
--- stderr\n\
}}
"#,
p.root().join("target").join("native").join("foo-").display()));
- assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(build.cargo_process("build"), execs().with_status(0));
p = p
.file("src/foo.rs", r#"
fn main() {}
"#);
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
})
test!(crate_version_env_vars {
}
"#);
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(
process(p.bin("foo")),
execs().with_stdout(format!("0-5-1 @ alpha.1 in {}\n",
p.root().display()).as_slice()));
- assert_that(p.process(cargo_dir().join("cargo-test")), execs().with_status(0));
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
+ execs().with_status(0));
})
test!(custom_build_in_dependency {
}}
"#,
p.root().join("target/native/bar-").display()));
- assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(build.cargo_process("build"), execs().with_status(0));
p = p
.file("bar/src/lib.rs", r#"
pub fn bar() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0));
})
.file("bar/src/lib.rs", r#"
pub fn bar() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0));
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0));
})
.file("src/foo.rs", r#"
pub fn foo() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0));
let files = fs::readdir(&p.root().join("target")).assert();
.file("src/lib.rs", r#"
pub fn foo() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0));
let files = fs::readdir(&p.root().join("target")).assert();
.file("src/foo.rs", r#"
pub fn foo() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stderr("unused manifest key: project.bulid\n"));
.file("src/foo.rs", r#"
pub fn foo() {}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stderr("unused manifest key: lib.build\n"));
})
name = "test"
"#)
.file("src/test.rs", "fn main() {}");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0));
})
.file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice())
.symlink("Notafile", "bar");
- assert_that(p.cargo_process("cargo-build"), execs());
+ assert_that(p.cargo_process("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(
version = "0.0.0"
authors = []
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(101)
.with_stderr("either a [lib] or [[bin]] section \
must be present\n"));
authors = []
"#)
.file("src/lib.rs", "");
- assert_that(p.cargo_process("cargo-build").arg("-v"),
+ assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0).with_stdout(format!("\
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type lib \
-C metadata=[..] \
authors = []
"#)
.file("src/lib.rs", "");
- assert_that(p.cargo_process("cargo-build").arg("-v").arg("--release"),
+ assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0).with_stdout(format!("\
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type lib \
--opt-level 3 \
crate_type = ["dylib", "rlib"]
"#)
.file("foo/src/lib.rs", "");
- assert_that(p.cargo_process("cargo-build").arg("-v").arg("--release"),
+ assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0).with_stdout(format!("\
{running} `rustc {dir}{sep}foo{sep}src{sep}lib.rs --crate-name foo \
--crate-type dylib --crate-type rlib \
fn main() { println!("{}, {}!", world::get_goodbye(), world::get_world()); }
"#);
- assert_that(p.cargo_process("cargo-test"), execs());
+ assert_that(p.cargo_process("test"), execs());
assert_that(process(p.bin("hello")), execs().with_stdout("Hello, World!\n"));
assert_that(process(p.bin("goodbye")), execs().with_stdout("Goodbye, World!\n"));
})
fn main() { println!("{}, {}!", world::get_goodbye(), world::get_world()); }
"#);
- assert_that(p.cargo_process("cargo-test"), execs().with_status(0));
+ assert_that(p.cargo_process("test"), execs().with_status(0));
assert_that(process(p.bin("hello")), execs().with_stdout("Hello, World!\n"));
assert_that(process(p.bin("goodbye")), execs().with_stdout("Goodbye, World!\n"));
})
}
"#);
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(p.bin("foo")), execs().with_stdout("slow\n"));
})
}
"#);
- assert_that(p.cargo_process("cargo-build").arg("--release"),
+ assert_that(p.cargo_process("build").arg("--release"),
execs().with_status(0));
assert_that(process(p.bin("release/foo")), execs().with_stdout("fast\n"));
})
fn main() {}
"#);
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(p.bin("foo")), execs().with_status(0));
})
"#)
.file("bar/src/lib.rs", "");
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
let p = p.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
"#);
- assert_that(p.cargo_process("cargo-build"), execs().with_status(101));
+ assert_that(p.cargo_process("build"), execs().with_status(101));
})
test!(bad_cargo_toml_in_target_dir {
"#)
.file("target/Cargo.toml", "bad-toml");
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
assert_that(process(p.bin("foo")), execs().with_status(0));
})
fn main() { syntax::foo() }
");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} syntax v0.0.1 ({dir})
"#)
.file("src/lib.rs", "pub fn foo() {}");
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
})
test!(opt_out_of_lib {
"#)
.file("src/lib.rs", "bad syntax")
.file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
})
test!(opt_out_of_bin {
"#)
.file("src/lib.rs", "")
.file("src/main.rs", "bad syntax");
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
})
test!(single_lib {
path = "src/bar.rs"
"#)
.file("src/bar.rs", "");
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
})
test!(deprecated_lib {
name = "foo"
"#)
.file("src/foo.rs", "");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stderr("\
the [[lib]] section has been deprecated in favor of [lib]\n"));
foo.build();
foo.root().move_into_the_past().assert();
- assert_that(foo.process(cargo_dir().join("cargo-build")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.0 ({url})
// Smoke test to make sure it doesn't compile again
println!("first pass");
- assert_that(foo.process(cargo_dir().join("cargo-build")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} foo v0.0.0 ({url})
// Modify an ignored file and make sure we don't rebuild
println!("second pass");
File::create(&foo.root().join("src/bar.rs")).assert();
- assert_that(foo.process(cargo_dir().join("cargo-build")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} foo v0.0.0 ({url})
}
}}
"#);
- assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(build.cargo_process("build"), execs().with_status(0));
let foo = project("foo")
.file("Cargo.toml", format!(r#"
foo.build();
foo.root().move_into_the_past().assert();
- assert_that(foo.process(cargo_dir().join("cargo-build"))
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build")
.env("FIRST", Some("1")),
execs().with_status(0)
.with_stdout(format!("\
", compiling = COMPILING, url = foo.url())));
File::create(&foo.root().join("src/bar.rs")).assert();
- assert_that(foo.process(cargo_dir().join("cargo-build")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.0 ({url})
let root = project.root();
let git_root = git_project.root();
- assert_that(project.cargo_process("cargo-build"),
+ assert_that(project.cargo_process("build"),
execs()
.with_stdout(format!("{} git repository `{}`\n\
{} dep1 v0.5.0 ({}#[..])\n\
let root = project.root();
let git_root = git_project.root();
- assert_that(project.cargo_process("cargo-build"),
+ assert_that(project.cargo_process("build"),
execs()
.with_stdout(format!("{} git repository `{}`\n\
{} dep1 v0.5.0 ({}?ref=branchy#[..])\n\
let root = project.root();
let git_root = git_project.root();
- assert_that(project.cargo_process("cargo-build"),
+ assert_that(project.cargo_process("build"),
execs()
.with_stdout(format!("{} git repository `{}`\n\
{} dep1 v0.5.0 ({}?ref=v0.1.0#[..])\n\
.file("src/parent.rs",
main_file(r#""{}", dep1::hello()"#, ["dep1"]).as_slice());
- p.cargo_process("cargo-build")
+ p.cargo_process("build")
.exec_with_output()
.assert();
.file("src/parent.rs",
main_file(r#""{} {}", dep1::hello(), dep2::hello()"#, ["dep1", "dep2"]).as_slice());
- p.cargo_process("cargo-build")
+ p.cargo_process("build")
.exec_with_output()
.assert();
"#, url))
.file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
- assert_that(project.cargo_process("cargo-build"),
+ assert_that(project.cargo_process("build"),
execs()
.with_stdout("")
.with_stderr(format!("Cargo.toml is not a valid manifest\n\n\
baz.build();
// TODO: -j1 is a hack
- assert_that(foo.cargo_process("cargo-build").arg("-j").arg("1"),
+ assert_that(foo.cargo_process("build").arg("-j").arg("1"),
execs().with_status(0));
assert_that(&foo.bin("foo"), existing_file());
assert_that(foo.process(foo.bin("foo")), execs().with_status(0));
main_file(r#""{}", bar::bar()"#, ["bar"]).as_slice());
// First time around we should compile both foo and bar
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("{} git repository `{}`\n\
{} bar v0.5.0 ({}#[..])\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url())));
// Don't recompile the second time
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({}#[..])\n\
{} foo v0.5.0 ({})\n",
FRESH, git_project.url(),
pub fn bar() { println!("hello!"); }
"#).assert();
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({}#[..])\n\
{} foo v0.5.0 ({})\n",
FRESH, git_project.url(),
FRESH, p.url())));
- assert_that(p.process(cargo_dir().join("cargo-update")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("update"),
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({}#[..])\n\
{} foo v0.5.0 ({})\n",
FRESH, git_project.url(),
.assert();
println!("compile after commit");
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({}#[..])\n\
{} foo v0.5.0 ({})\n",
FRESH, git_project.url(),
p.root().move_into_the_past().assert();
// Update the dependency and carry on!
- assert_that(p.process(cargo_dir().join("cargo-update")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("update"),
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
println!("going for the last compile");
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({}#[..])\n\
{} foo v0.5.0 ({})\n",
COMPILING, git_project.url(),
.file("dep2/src/lib.rs", "");
// First time around we should compile both foo and bar
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("\
{updating} git repository `{git}`
{compiling} bar v0.5.0 ({git}#[..])
timer::sleep(Duration::milliseconds(1000));
- assert_that(p.process(cargo_dir().join("cargo-update")).arg("dep1"),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("update").arg("dep1"),
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
// Make sure we still only compile one version of the git repo
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("\
{compiling} bar v0.5.0 ({git}#[..])
{compiling} [..] v0.5.0 ({dir})
compiling = COMPILING, dir = p.url())));
// We should be able to update transitive deps
- assert_that(p.process(cargo_dir().join("cargo-update")).arg("bar"),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("update").arg("bar"),
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
pub fn foo() { dep1::dep() }
");
- assert_that(project.cargo_process("cargo-build"),
+ assert_that(project.cargo_process("build"),
execs().with_stderr("").with_status(0));
})
"#, git1.url(), git2.url()))
.file("src/main.rs", "fn main() {}");
- assert_that(project.cargo_process("cargo-build"),
+ assert_that(project.cargo_process("build"),
execs()
.with_stdout(format!("{} git repository `[..]`\n\
{} git repository `[..]`\n\
git1.process("git").args(["commit", "-m", "test"]).exec_with_output()
.assert();
- assert_that(project.process(cargo_dir().join("cargo-update")).arg("dep1"),
+ assert_that(project.process(cargo_dir().join("cargo")).arg("update").arg("dep1"),
execs()
.with_stdout(format!("{} git repository `{}`\n",
UPDATING, git1.url()))
fn main() { assert_eq!(bar::bar(), 1) }
"#);
- assert_that(foo.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(foo.cargo_process("build"), execs().with_status(0));
assert_that(foo.process(foo.bin("foo")), execs().with_status(0));
// Update the repo, and simulate someone else updating the lockfile and then
"#, url = bar.url(), hash = rev).as_slice()).assert();
// Now build!
- assert_that(foo.process(cargo_dir().join("cargo-build")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{updating} git repository `{bar}`
pub fn main() { println!(\"{}\", dep1::dep()) }
");
- assert_that(project.cargo_process("cargo-run"), execs()
+ assert_that(project.cargo_process("run"), execs()
.with_stdout(format!("{} git repository `[..]`\n\
{} dep1 v0.5.0 ([..])\n\
{} foo v0.5.0 ([..])\n\
timer::sleep(Duration::milliseconds(1000));
// Update the dependency and carry on!
- assert_that(project.process(cargo_dir().join("cargo-update")), execs()
+ assert_that(project.process(cargo_dir().join("cargo")).arg("update"), execs()
.with_stderr("")
.with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
- assert_that(project.cargo_process("cargo-run"), execs()
+ assert_that(project.cargo_process("run"), execs()
.with_stdout(format!("{} git repository `[..]`\n\
{} dep1 v0.5.0 ([..])\n\
{} foo v0.5.0 ([..])\n\
// Generate a lockfile which did not use `bar` to compile, but had to update
// `bar` to generate the lockfile
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("\
{updating} git repository `{bar}`
{compiling} foo v0.5.0 ({url})
// Make sure we use the previous resolution of `bar` instead of updating it
// a second time.
- assert_that(p.process(cargo_dir().join("cargo-test")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_stdout(format!("\
{compiling} bar v0.5.0 ({bar}#[..])
{compiling} foo v0.5.0 ({url})
timer::sleep(Duration::milliseconds(1000));
- assert_that(foo.process(cargo_dir().join("cargo-build")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.0 ({url})
// Smoke test to make sure it doesn't compile again
println!("first pass");
- assert_that(foo.process(cargo_dir().join("cargo-build")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} foo v0.0.0 ({url})
// Modify an ignored file and make sure we don't rebuild
println!("second pass");
File::create(&foo.root().join("src/bar.rs")).assert();
- assert_that(foo.process(cargo_dir().join("cargo-build")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} foo v0.0.0 ({url})
}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
"#);
p2.build();
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(101))
})
"#);
p2.build();
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_stdout(format!("\
{compiling} bar v0.5.0 ({url})
{compiling} foo v0.5.0 ({url})
}
"#);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
"#);
let bar = path2url(bar);
// First time around we should compile both foo and bar
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
COMPILING, bar,
COMPILING, p.url())));
// This time we shouldn't compile bar
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
FRESH, bar,
p.root().move_into_the_past().assert();
p.build(); // rebuild the files (rewriting them in the process)
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
COMPILING, bar,
"#);
let baz = path2url(baz);
let bar = path2url(bar);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
COMPILING, baz,
COMPILING, bar,
COMPILING, p.url())));
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
File::create(&p.root().join("baz/src/baz.rs")).write_str(r#"
pub fn baz() { println!("hello!"); }
"#).assert();
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
extern crate baz;
pub fn bar() { println!("hello!"); baz::baz(); }
"#).assert();
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
"#);
let baz = path2url(baz);
let bar = path2url(bar);
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
COMPILING, bar,
COMPILING, p.url())));
assert_that(&p.bin("foo"), existing_file());
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
.file("src/bar/src/bar.rs", "pub fn gimme() {}");
let bar = p.url();
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
COMPILING, bar,
"#).assert();
// This shouldn't recompile `bar`
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
{} foo v0.5.0 ({})\n",
FRESH, bar,
"#)
.file("src/bar/not-a-manifest", "");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs()
.with_status(101)
.with_stderr(format!("Could not find `Cargo.toml` in `{}`\n",
.file("src/main.rs", "fn main() {}");
bar.build();
- assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+ assert_that(p.cargo_process("build"), execs().with_status(0));
})
bar.build();
baz.build();
- assert_that(foo.cargo_process("cargo-build"),
+ assert_that(foo.cargo_process("build"),
execs().with_status(0));
- assert_that(foo.process(cargo_dir().join("cargo-doc")),
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("doc"),
execs().with_status(0));
})
assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
}}
"#, alternate()).as_slice());
- assert_that(build.cargo_process("cargo-build"),
+ assert_that(build.cargo_process("build"),
execs().with_status(0));
let p = project("foo")
"#);
let target = alternate();
- assert_that(p.cargo_process("cargo-build").arg("--target").arg(target),
+ assert_that(p.cargo_process("build").arg("--target").arg(target),
execs().with_status(0));
assert_that(&p.target_bin(target, "foo"), existing_file());
p2.build();
let target = alternate();
- assert_that(p.cargo_process("cargo-build").arg("--target").arg(target),
+ assert_that(p.cargo_process("build").arg("--target").arg(target),
execs().with_status(0));
assert_that(&p.target_bin(target, "foo"), existing_file());
baz.build();
let target = alternate();
- assert_that(foo.cargo_process("cargo-build").arg("--target").arg(target),
+ assert_that(foo.cargo_process("build").arg("--target").arg(target),
execs().with_status(0));
assert_that(&foo.target_bin(target, "foo"), existing_file());
baz.build();
let target = alternate();
- assert_that(foo.cargo_process("cargo-build").arg("--target").arg(target),
+ assert_that(foo.cargo_process("build").arg("--target").arg(target),
execs().with_status(0));
- assert_that(foo.process(cargo_dir().join("cargo-build"))
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("build")
.arg("--target").arg(target),
execs().with_status(0));
assert_that(&foo.target_bin(target, "foo"), existing_file());
}
"#);
- assert_that(p.cargo_process("cargo-build").arg("--target").arg(target)
+ assert_that(p.cargo_process("build").arg("--target").arg(target)
.arg("-v"),
execs().with_status(101)
.with_stdout(format!("\
baz.build();
let target = alternate();
- assert_that(foo.cargo_process("cargo-build").arg("--target").arg(target),
+ assert_that(foo.cargo_process("build").arg("--target").arg(target),
execs().with_status(0));
})
"#);
let target = alternate();
- assert_that(p.cargo_process("cargo-test").arg("--target").arg(target),
+ assert_that(p.cargo_process("test").arg("--target").arg(target),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.0 ({foo})
pub fn foo() {}
"#);
- assert_that(p.cargo_process("cargo-doc"),
+ assert_that(p.cargo_process("doc"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
",
bad code
"#);
- assert_that(p.cargo_process("cargo-doc"),
+ assert_that(p.cargo_process("doc"),
execs().with_status(0));
})
pub fn foo() {}
"#);
- assert_that(p.cargo_process("cargo-doc"),
+ assert_that(p.cargo_process("doc"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
",
compiling = COMPILING,
dir = path2url(p.root())).as_slice()));
- assert_that(p.process(cargo_dir().join("cargo-doc")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("doc"),
execs().with_status(0).with_stdout(format!("\
{fresh} foo v0.0.1 ({dir})
",
pub fn bar() {}
"#);
- assert_that(p.cargo_process("cargo-doc"),
+ assert_that(p.cargo_process("doc"),
execs().with_status(0).with_stdout(format!("\
{compiling} bar v0.0.1 ({dir})
{compiling} foo v0.0.1 ({dir})
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
- assert_that(p.process(cargo_dir().join("cargo-doc"))
+ assert_that(p.process(cargo_dir().join("cargo")).arg("doc")
.env("RUST_LOG", Some("cargo::ops::cargo_rustc::fingerprint")),
execs().with_status(0).with_stdout(format!("\
{fresh} bar v0.0.1 ({dir})
pub fn bar() {}
"#);
- assert_that(p.cargo_process("cargo-doc").arg("--no-deps"),
+ assert_that(p.cargo_process("doc").arg("--no-deps"),
execs().with_status(0).with_stdout(format!("\
{compiling} bar v0.0.1 ({dir})
{compiling} foo v0.0.1 ({dir})
pub fn bar() {}
"#);
- assert_that(p.cargo_process("cargo-doc"),
+ assert_that(p.cargo_process("doc"),
execs().with_status(0));
assert_that(&p.root().join("target/doc"), existing_dir());
.file("src/main.rs", "fn main() {}")
.file("src/lib.rs", "fn foo() {}");
- assert_that(p.cargo_process("cargo-doc"),
+ assert_that(p.cargo_process("doc"),
execs().with_status(101)
.with_stderr("\
Cannot document a package where a library and a binary have the same name. \
"#)
.file("src/a.rs", "");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = path2url(p.root()))));
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(format!("\
{fresh} foo v0.0.1 ({dir})
", fresh = FRESH, dir = path2url(p.root()))));
p.root().move_into_the_past().assert();
File::create(&p.root().join("src/a.rs")).write_str("fn main() {}").assert();
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = path2url(p.root()))));
fs::rename(&p.root().join("src/a.rs"), &p.root().join("src/b.rs")).assert();
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(101));
})
.file("src/b.rs", "")
.file("tests/test.rs", "");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = path2url(p.root()))));
- assert_that(p.process(cargo_dir().join("cargo-test")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
File::create(&bin).write_str("fn foo() {}").assert();
// Make sure the binary is rebuilt, not the lib
- assert_that(p.process(cargo_dir().join("cargo-build"))
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build")
.env("RUST_LOG", Some("cargo::ops::cargo_rustc::fingerprint")),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
"#)
.file("src/a.rs", "");
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.cargo_process("build"),
execs().with_status(0));
let lockfile = p.root().join("Cargo.lock");
let lock = lock.assert();
let lock = lock.as_slice().replace("\n", "\r\n");
File::create(&lockfile).write_str(lock.as_slice()).assert();
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0));
})
"#)
.file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("cargo-generate-lockfile"),
+ assert_that(p.cargo_process("generate-lockfile"),
execs().with_status(0));
let lockfile = p.root().join("Cargo.lock");
[dependencies]
bar = "0.5.0"
"#).assert();
- assert_that(p.process(cargo_dir().join("cargo-generate-lockfile")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("generate-lockfile"),
execs().with_status(0));
let lock2 = File::open(&lockfile).read_to_string().assert();
assert!(lock1 != lock2);
[dependencies]
bar = "0.2.0"
"#).assert();
- assert_that(p.process(cargo_dir().join("cargo-generate-lockfile")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("generate-lockfile"),
execs().with_status(0));
let lock3 = File::open(&lockfile).read_to_string().assert();
assert!(lock1 != lock3);
authors = []
version = "0.0.1"
"#).assert();
- assert_that(p.process(cargo_dir().join("cargo-generate-lockfile")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("generate-lockfile"),
execs().with_status(0));
let lock4 = File::open(&lockfile).read_to_string().assert();
assert_eq!(lock1, lock4);
}
fn cargo_process(s: &str) -> ProcessBuilder {
- process(cargo_dir().join(s))
+ process(cargo_dir().join("cargo")).arg(s)
.cwd(paths::root())
.env("HOME", Some(paths::home()))
}
test!(simple_lib {
os::setenv("USER", "foo");
- assert_that(cargo_process("cargo-new").arg("foo"),
+ assert_that(cargo_process("new").arg("foo"),
execs().with_status(0));
assert_that(&paths::root().join("foo"), existing_dir());
assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
assert_that(&paths::root().join("foo/src/lib.rs"), existing_file());
- assert_that(cargo_process("cargo-build").cwd(paths::root().join("foo")),
+ assert_that(cargo_process("build").cwd(paths::root().join("foo")),
execs().with_status(0));
})
test!(simple_bin {
os::setenv("USER", "foo");
- assert_that(cargo_process("cargo-new").arg("foo").arg("--bin"),
+ assert_that(cargo_process("new").arg("foo").arg("--bin"),
execs().with_status(0));
assert_that(&paths::root().join("foo"), existing_dir());
assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
assert_that(&paths::root().join("foo/src/main.rs"), existing_file());
- assert_that(cargo_process("cargo-build").cwd(paths::root().join("foo")),
+ assert_that(cargo_process("build").cwd(paths::root().join("foo")),
execs().with_status(0));
assert_that(&paths::root().join(format!("foo/target/foo{}",
os::consts::EXE_SUFFIX)),
test!(simple_git {
os::setenv("USER", "foo");
- assert_that(cargo_process("cargo-new").arg("foo").arg("--git"),
+ assert_that(cargo_process("new").arg("foo").arg("--git"),
execs().with_status(0));
assert_that(&paths::root().join("foo"), existing_dir());
assert_that(&paths::root().join("foo/.git"), existing_dir());
assert_that(&paths::root().join("foo/.gitignore"), existing_file());
- assert_that(cargo_process("cargo-build").cwd(paths::root().join("foo")),
+ assert_that(cargo_process("build").cwd(paths::root().join("foo")),
execs().with_status(0));
})
test!(no_argument {
- assert_that(cargo_process("cargo-new"),
+ assert_that(cargo_process("new"),
execs().with_status(1)
.with_stderr("Invalid arguments.
Usage:
- cargo-new [options] <path>
- cargo-new -h | --help
+ cargo new [options] <path>
+ cargo new -h | --help
"));
})
test!(existing {
let dst = paths::root().join("foo");
fs::mkdir(&dst, UserRWX).assert();
- assert_that(cargo_process("cargo-new").arg("foo"),
+ assert_that(cargo_process("new").arg("foo"),
execs().with_status(101)
.with_stderr(format!("Destination `{}` already exists\n",
dst.display())));
})
test!(finds_author_user {
- assert_that(cargo_process("cargo-new").arg("foo").env("USER", Some("foo")),
+ assert_that(cargo_process("new").arg("foo").env("USER", Some("foo")),
execs().with_status(0));
let toml = paths::root().join("foo/Cargo.toml");
.exec().assert();
my_process("git").args(["config", "--global", "user.email", "baz"])
.exec().assert();
- assert_that(cargo_process("cargo-new").arg("foo").env("USER", Some("foo")),
+ assert_that(cargo_process("new").arg("foo").env("USER", Some("foo")),
execs().with_status(0));
let toml = paths::root().join("foo/Cargo.toml");
fn main() { println!("hello"); }
"#);
- assert_that(p.cargo_process("cargo-run"),
+ assert_that(p.cargo_process("run"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
{running} `target{sep}foo`
}
"#);
- assert_that(p.cargo_process("cargo-run").arg("hello").arg("world"),
+ assert_that(p.cargo_process("run").arg("hello").arg("world"),
execs().with_status(0));
})
fn main() { std::os::set_exit_status(2); }
"#);
- assert_that(p.cargo_process("cargo-run"),
+ assert_that(p.cargo_process("run"),
execs().with_status(2));
})
"#)
.file("src/lib.rs", "");
- assert_that(p.cargo_process("cargo-run"),
+ assert_that(p.cargo_process("run"),
execs().with_status(101)
.with_stderr("a bin target must be available \
for `cargo run`\n"));
.file("src/bin/a.rs", "")
.file("src/bin/b.rs", "");
- assert_that(p.cargo_process("cargo-run"),
+ assert_that(p.cargo_process("run"),
execs().with_status(101)
.with_stderr("`cargo run` requires that a project only \
have one executable\n"));
"#)
.file("bar/src/lib.rs", "pub fn bar() {}");
- assert_that(p.cargo_process("cargo-run").arg("hello").arg("world"),
+ assert_that(p.cargo_process("run").arg("hello").arg("world"),
execs().with_status(0));
})
fn main() { }
"#);
- assert_that(p.cargo_process("cargo-run"), execs().with_status(0));
+ assert_that(p.cargo_process("run"), execs().with_status(0));
})
assert_eq!(hello(), "hello")
}"#);
- assert_that(p.cargo_process("cargo-build"), execs());
+ assert_that(p.cargo_process("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(
process(p.bin("foo")),
execs().with_stdout("hello\n"));
- assert_that(p.process(cargo_dir().join("cargo-test")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_stdout(format!("\
{} foo v0.5.0 ({})
{} target[..]foo
#[test] fn test_hello() {}
"#);
- assert_that(p.cargo_process("cargo-test").arg("-v").arg("hello"),
+ assert_that(p.cargo_process("test").arg("-v").arg("hello"),
execs().with_stdout(format!("\
{running} `rustc src[..]foo.rs [..]`
{compiling} foo v0.5.0 ({url})
#[test] fn test_test() { foo::foo() }
"#);
- let output = p.cargo_process("cargo-test").exec_with_output().assert();
+ let output = p.cargo_process("test").exec_with_output().assert();
let output = str::from_utf8(output.output.as_slice()).assert();
assert!(output.contains("test bin_test"), "bin_test missing\n{}", output);
assert!(output.contains("test lib_test"), "lib_test missing\n{}", output);
assert_eq!(hello(), "nope")
}"#);
- assert_that(p.cargo_process("cargo-build"), execs());
+ assert_that(p.cargo_process("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(
process(p.bin("foo")),
execs().with_stdout("hello\n"));
- assert_that(p.process(cargo_dir().join("cargo-test")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_stdout(format!("\
{} foo v0.5.0 ({})
{} target[..]foo
fn bin_test() {}
");
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_stdout(format!("\
{} foo v0.0.1 ({})
{running} target[..]baz-[..]
");
p2.build();
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
fn external_test() { assert_eq!(foo::get_hello(), "Hello") }
"#);
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_stdout(format!("\
{} foo v0.0.1 ({})
{running} target[..]foo-[..]
fn external_test() { assert_eq!(foo::get_hello(), "Hello") }
"#);
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_stdout(format!("\
{} foo v0.0.1 ({})
{running} target[..]external-[..]
.file("examples/dont-run-me-i-will-fail.rs", r#"
fn main() { fail!("Examples should not be run by 'cargo test'"); }
"#);
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_status(0));
})
#[test] fn bar() {}
");
- assert_that(p.cargo_process("cargo-test").arg("bar"),
+ assert_that(p.cargo_process("test").arg("bar"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
doctest = DOCTEST,
dir = p.url()).as_slice()));
- assert_that(p.cargo_process("cargo-test").arg("foo"),
+ assert_that(p.cargo_process("test").arg("foo"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
fn dummy_test() { }
"#);
- p.cargo_process("cargo-build");
+ p.cargo_process("build");
for _ in range(0u, 2) {
- assert_that(p.process(cargo_dir().join("cargo-test")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_status(0));
}
})
fn bin_test() {}
");
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_stdout(format!("\
{} foo v0.0.1 ({})
{running} target[..]foo-[..]
fn test() { syntax::foo() }
");
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} syntax v0.0.1 ({dir})
fn test() { syntax::foo() }
");
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} syntax v0.0.1 ({dir})
}
"#);
- let output = p.cargo_process("cargo-test").exec_with_output().assert();
+ let output = p.cargo_process("test").exec_with_output().assert();
let output = str::from_utf8(output.output.as_slice()).assert();
assert!(output.contains("main_test ... ok"), "no main_test\n{}", output);
assert!(output.contains("test_test ... ok"), "no test_test\n{}", output);
pub fn baz() {}
");
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} bar v0.0.1 ({dir})
doctest = DOCTEST,
dir = p.url()).as_slice()));
p.root().move_into_the_past().assert();
- assert_that(p.process(cargo_dir().join("cargo-test")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} bar v0.0.1 ({dir})
fn foo() {}
");
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
doctest = DOCTEST,
dir = p.url()).as_slice()));
- assert_that(p.process(cargo_dir().join("cargo-test")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} foo v0.0.1 ({dir})
fn foo() {}
");
- assert_that(p.cargo_process("cargo-test"),
+ assert_that(p.cargo_process("test"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
doctest = DOCTEST,
dir = p.url()).as_slice()));
- assert_that(p.process(cargo_dir().join("cargo-build")),
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0)
.with_stdout(format!("\
{fresh} foo v0.0.1 ({dir})
fn foo() { fail!() }
");
- assert_that(p.cargo_process("cargo-test").arg("--no-run"),
+ assert_that(p.cargo_process("test").arg("--no-run"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
test!(simple {
let p = project("foo");
- assert_that(p.cargo_process("cargo-version"),
+ assert_that(p.cargo_process("version"),
execs().with_status(0).with_stdout(format!("{}\n",
cargo::version()).as_slice()));
})